// pages/warehouse/warehouse.js
var app = getApp()

Page({

  /**
   * 页面的初始数据
   */
  data: {
    mycurrent: '待签收',
    user: wx.getStorageSync('user'),
    myList:''
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.setData({
      user: wx.getStorageSync('user')
    })
  },
  getlist: function () {
    var that = this
    wx.request({
      url: app.globalData.api + 'warehouse/list',
      data: {
        "keyword": "",
        "orderBy": "createTime_desc",
        "status": this.data.mycurrent,
        "businessManagerId": "",
        "timeRange": "",
        "page": "",
        "rows": 99
      },
      header: {
        Authorization: wx.getStorageSync('token')
      },
      method: 'POST',
      success: function (res) {
        console.log(res)
        if (res.data.code == 200) {
          that.setData({
            myList: res.data.data.warehouseList
          })
        } else {
          that.setData({
            myList: []
          })
        }
      }
    })
  },
  MyonChange(e) {
    console.log('onChange', e)
    this.setData({
      mycurrent: e.detail.key,
    })
    this.getlist()

  },
  signFor: (e) => {
    wx.navigateTo({
      // url: '/pages/signFor/signFor?id=' + e.currentTarget.dataset.id
      url: '/pages/warehouse_order/warehouse_order?id=' + e.currentTarget.dataset.id
    })
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
    this.setData({
      user: wx.getStorageSync('user')
    })
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getlist()
    this.setData({
      user: wx.getStorageSync('user')
    })
  },
  goImg(e) {
    wx.request({
      url: app.globalData.api + 'designDiagram/findDesignDiagramStyleNumber/' + e.currentTarget.dataset.imgid,
      data: '',
      header: {
        Authorization: wx.getStorageSync('token')
      },
      success: function (res) {
        if (res.data.code == 200) {
          wx.navigateTo({
            url: '/pages/details/details?id=' + res.data.data.id,
          })
        } else {
          wx.showModal({
            title: '提示',
            content: res.data.errorMsg,
          })
        }

      }
    })

  },
  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {

  }
})